<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class HouseCostsOrderCreateRequest extends BasicRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
    	// 可选的发票配送方式
    	$invoice_type = config('basic.invoice_type');
		$invoice_type_in = array_field_1($invoice_type,'type');
		// 可选的支付方式
		$pay_type = config('basic.pay_type');
		$pay_type_in = array_field_1($pay_type,'type');
        return [
			'id'			=> 'bail|required|json',
			'invoice_type'	=> ['bail','required',Rule::in($invoice_type_in)],
			'pay_type'		=> ['bail','required',Rule::in($pay_type_in)],
        ];
    }
    
    public function messages()
	{
		return [
			'id.required'			=> '请选择需要缴纳的费用',
			'id.json'				=> '费用类型传值错误',
			'invoice_type.required'	=> '请选择发票配送方式',
			'invoice_type.in'		=> '发票配送方式选择有误',
			'pay_type.required'		=> '请选择缴费方式',
			'pay_type.in'			=> '支付方式有误',
		];
	}
}
